package test.controller;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

import test.model.Greeting;

/**
 * Copyright © 2018 掌上医讯. All rights reserved.
 * 
 * @Title: LoginController.java
 * @Prject: springwebsocket
 * @Package: test.controller
 * @Description: TODO
 * @author: QuZening
 * @date: 2018年3月21日 上午11:27:19
 * @version: V1.0
 */
@Component
@RabbitListener(queues = "hello")
public class HelloReceiver {
	
	@Autowired
	private SimpMessagingTemplate simpMessagingTemplate;

    @RabbitHandler
    public void process(String hello) {
        System.out.println("Receiver  : " + hello);
        simpMessagingTemplate.convertAndSendToUser("admin", "/topic/greetings", new Greeting(hello));
    }

}
